<?php

/**
 * This is the model class for table "competency_model".
 *
 * The followings are the available columns in table 'competency_model':
 * @property integer $COMP_MODEL_ID
 * @property integer $JOB_TITLE_ID
 * @property integer $COMP_CAT_ID
 * @property integer $JLR
 * @property string $COMP_LIB_CODE
 * @property string $TIME_CREATED
 * @property integer $USER_CREATED
 * @property string $TIME_UPDATED
 * @property integer $USER_UPDATED
 *
 * The followings are the available model relations:
 * @property CompetencyLibrary $cOMPLIBCODE
 * @property JobTitle $jOBTITLE
 * @property CompetencyCategory $cOMPCAT
 */
class CompetencyModel extends CMasterModel
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return CompetencyModel the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'competency_model';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('JOB_TITLE_ID, COMP_CAT_ID, JLR', 'required'),
			array('JOB_TITLE_ID, COMP_CAT_ID, JLR, USER_CREATED, USER_UPDATED', 'numerical', 'integerOnly'=>true),
			array('COMP_LIB_CODE', 'length', 'max'=>10),
			array('TIME_CREATED, TIME_UPDATED', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('COMP_MODEL_ID, JOB_TITLE_ID, COMP_CAT_ID, JLR, COMP_LIB_CODE, TIME_CREATED, USER_CREATED, TIME_UPDATED, USER_UPDATED', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'cOMPLIBCODE' => array(self::BELONGS_TO, 'CompetencyLibrary', 'COMP_LIB_CODE'),
			'jOBTITLE' => array(self::BELONGS_TO, 'JobTitle', 'JOB_TITLE_ID'),
			'cOMPCAT' => array(self::BELONGS_TO, 'CompetencyCategory', 'COMP_CAT_ID'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'COMP_MODEL_ID' => 'Comp Model',
			'JOB_TITLE_ID' => 'Job Title',
			'COMP_CAT_ID' => 'Comp Cat',
			'JLR' => 'Jlr',
			'COMP_LIB_CODE' => 'Comp Lib Code',
			'TIME_CREATED' => 'Time Created',
			'USER_CREATED' => 'User Created',
			'TIME_UPDATED' => 'Time Updated',
			'USER_UPDATED' => 'User Updated',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('COMP_MODEL_ID',$this->COMP_MODEL_ID);
		$criteria->compare('JOB_TITLE_ID',$this->JOB_TITLE_ID);
		$criteria->compare('COMP_CAT_ID',$this->COMP_CAT_ID);
		$criteria->compare('JLR',$this->JLR);
		$criteria->compare('COMP_LIB_CODE',$this->COMP_LIB_CODE,true);
		$criteria->compare('TIME_CREATED',$this->TIME_CREATED,true);
		$criteria->compare('USER_CREATED',$this->USER_CREATED);
		$criteria->compare('TIME_UPDATED',$this->TIME_UPDATED,true);
		$criteria->compare('USER_UPDATED',$this->USER_UPDATED);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}